// pages/account/account.js
Page({
  /**
   * 页面的初始数据
   */
  data: {
    password:'123456',
    account :'hdsj001',
    showAccount:false,

  }, 
  rules: {
    password: [
      { required: true, message: '请填写账号!' },
      { pattern: /^[a-zA-Z][a-zA-Z0-9_]{4,15}$/, message: '请检查账号是否正确!' },
    ],
    account: [
      { required: true, message: '请填写密码!' },
      { pattern: /^[0-9]{6,18}$/, message: '请检查密码是否正确!' }
    ]
  },
  // onLoad(){
  //     this.getLogin()
  // },
  // async getLogin(){
  //     // 请求验证码
  //     const {code,msg,data} =await wx.$http.post('/driver/login/account',{password:this.data.password,account:this.data.account})
  //     console.log(code,msg,data);
  // },
  async hLogin(){
     // 请求验证码
     const res =await wx.$http.post('/driver/login/account',{password:this.data.password,account:this.data.account})
    //  console.log(res);
     const token =res
      //  保存token
    const app =getApp()
    app.setToken('token',token)
    // 页面跳转
    const url= '/pages/index/index'
    wx.switchTab({
    url,
    })
     wx.$toast('登录成功')
  },
  hChaHao(){
    this.setData({password:''})
  },
  hClick(){
    this.setData({showAccount:!this.data.showAccount})
  }
})